package com.amit.Basic_Simple_Program;

import java.util.Scanner;

public class Npr_Ncr {

	public static void main(String[] args) {
		
		int n,r;
		
		System.out.println("Please enter the value of n and r");
		
		Scanner sc=new Scanner(System.in);
		
		 n=sc.nextInt();
		
		 r=sc.nextInt();
		 
		 
		 int npr=npr(n,r);
		 System.out.println("npr"+" "+npr);
		 int ncr=ncr(n,r);
		 System.out.println("ncr"+" "+ncr);
		
	}

	private static int ncr(int n, int r) {
		
		int result1=factorial(n)/((factorial(r))*(factorial(n-r)));
		
		return result1;
	}

	private static int npr(int n, int r) {
		
		int result=factorial(n)/factorial(n-r);
		
		
		return result;
	}

	private static int factorial(int n) {
		int factorial=1;
		for(int i=1;i<=n;i++)
		{
			factorial=factorial*i;
		}
		
		
		return factorial;
	}

}
